import random

# 生成正面评价的模板
positive_templates = [
    "This movie was absolutely {adjective}! The {aspect} was {positive_adj}, and I was {emotion} throughout.",
    "A {adjective} masterpiece! The {aspect} was {positive_adj}, and the {aspect} kept me hooked.",
    "I loved every minute of this film. The {aspect} was {positive_adj}, and the {aspect} was {positive_adj}.",
    "The {aspect} was {positive_adj}, and the {aspect} was {positive_adj}. Highly recommend!",
    "One of the best movies I've seen in years. The {aspect} was {positive_adj}, and the {aspect} was {positive_adj}.",
]

# 生成负面评价的模板
negative_templates = [
    "This movie was a complete {negative_adj}. The {aspect} was {negative_adj}, and I was {emotion} throughout.",
    "A {negative_adj} disappointment! The {aspect} was {negative_adj}, and the {aspect} was {negative_adj}.",
    "I couldn't even finish watching it. The {aspect} was {negative_adj}, and the {aspect} was {negative_adj}.",
    "The {aspect} was {negative_adj}, and the {aspect} was {negative_adj}. Not worth watching.",
    "One of the worst movies I've seen in years. The {aspect} was {negative_adj}, and the {aspect} was {negative_adj}.",
]

# 可选的词汇
adjectives = ["fantastic", "amazing", "incredible", "brilliant", "captivating", "heartwarming", "thrilling"]
negative_adjectives = ["disappointing", "boring", "predictable", "terrible", "awful", "cringe-worthy", "uninspired"]
aspects = ["acting", "storyline", "cinematography", "soundtrack", "dialogue", "character development", "pacing"]
emotions = ["thrilled", "moved", "excited", "captivated", "inspired", "entertained"]
negative_emotions = ["bored", "frustrated", "disappointed", "annoyed", "confused", "unimpressed"]

# 生成一条评论
def generate_review(templates, adjectives, aspects, emotions, is_positive=True):
    template = random.choice(templates)
    if is_positive:
        adjective = random.choice(adjectives)
        positive_adj = random.choice(adjectives)
        emotion = random.choice(emotions)
    else:
        adjective = random.choice(negative_adjectives)
        positive_adj = random.choice(negative_adjectives)
        emotion = random.choice(negative_emotions)
    aspect1 = random.choice(aspects)
    aspect2 = random.choice(aspects)
    while aspect2 == aspect1:
        aspect2 = random.choice(aspects)
    review = template.format(
        adjective=adjective,
        positive_adj=positive_adj,
        aspect=aspect1,
        emotion=emotion,
        negative_adj=adjective,
    )
    return review

# 生成 400 条评论
positive_reviews = [generate_review(positive_templates, adjectives, aspects, emotions, is_positive=True) for _ in range(200)]
negative_reviews = [generate_review(negative_templates, negative_adjectives, aspects, negative_emotions, is_positive=False) for _ in range(200)]

# 合并所有评论
all_reviews = positive_reviews + negative_reviews

# 打印前 10 条正面和负面评论
print("=== Positive Reviews ===")
for i, review in enumerate(positive_reviews[:10]):
    print(f"{i+1}. {review}")

print("\n=== Negative Reviews ===")
for i, review in enumerate(negative_reviews[:10]):
    print(f"{i+1}. {review}")

# 保存到文件
with open("datasets/IMDB/aclImdb_v1/test/pos", "w", encoding="utf-8") as f:
    for review in all_reviews:
        f.write(review + "\n")

print("\nGenerated 400 reviews and saved to 'pos'.")